provider "alicloud" {
  profile = "default"
  version = "1.153.0"
}

data "alicloud_zones" "all" {
}

module "vpc" {
  source = "../../2-vpc"

  vpc_name        = "ebike"
  vpc_cidr        = "192.168.0.0/16"
  vpc_description = "测试vpc"
  vpc_tags = {
    created = "Terraform"
  }

  vswitch_name       = "ebike"
  availability_zones = data.alicloud_zones.all.ids
  vswitch_cidrs      = [for i, v in data.alicloud_zones.all.ids : format("192.168.%d.0/24", i + 1)]
  vswitch_tags = {
    created = "Terraform"
  }

}

module "security" {
  source = "../"

  name = "default"
  vpc_id = module.vpc.vpc_id
  description = "default group"

  key_pair_name = "tf-default"
  public_key_file = file("${path.module}/public.pem")
}

output "f1" {
  value = module.security.key_name
}

output "f2" {
  value = module.security.security_group_ids
}